***** RUN DO_MASTER.do ***** do "$Do_files\DO_MASTER.do"

global program "OA_TableB313"
cap log close
cap log using "$Log_files\log_$program$today", replace

**** REPLICATION OF TABLE B.3.13 ****

clear all
set mem 2g
set more off

// Import data

use $Data\data_news_voting, clear

// Get controls

global ctrl_base	"sh_lde lpop_A sh_F sh_F_new sh_cspsup sh_sec sh_ter lmean_reink lmean_reink2 charact_altitude charact_altitude_std sh_active sh_young sh_prot sh_M mk com_property" // ptySR_F_N" //  com_property"
global ctrl_plus	"mean_votation lcrSR_F_N"
global fe			"charact_agglo"
global fe_iv		"I_charact_agglo_*"
global cluster		"charact_agglo"

// Column 1

cap drop instr
g instr=instr_dev_v1_mk
	
reghdfe oui instr $ctrl_plus $ctrl_base ///
	if sample_hq00dstr==1, ///
	vce(cluster $cluster) absorb($fe) keepsing	
estimates store RF_V1

// Column 2

reghdfe oui $ctrl_plus $ctrl_base (endog_mk = instr) ///
	if sample_hq00dstr==1, ///
	vce(cluster $cluster) absorb($fe) stages(first, eform(exp(beta))) keepsing old
estimates store TSLS_V1
scalar f = e(rkf)
estadd scalar F_fs=f

// Column 3

cap drop instr
g instr=instr_dev_v2_mk
	
reghdfe oui instr $ctrl_plus $ctrl_base ///
	if sample_hq00dstr==1, ///
	vce(cluster $cluster) absorb($fe) keepsing	
estimates store RF_V2

// Column 4

reghdfe oui $ctrl_plus $ctrl_base (endog_mk = instr) ///
	if sample_hq00dstr==1, ///
	vce(cluster $cluster) absorb($fe) stages(first, eform(exp(beta))) keepsing old
estimates store TSLS_V2
scalar f = e(rkf)
estadd scalar F_fs=f

// Labels

la var endog_mk 		"Crime News Exposure ($ \mathtt{CNE} $)"
la var instr		 	"[0.1em] HQ Crime Prop. Diff. ($ \mathtt{HQC} $) - Expected $ \mathtt{HQC} $"
la var lcrSR_F_N 		"[0.1em] Local Crime Propensity Differential ($ \mathtt{CPD} $)"
la var mean_votation 	"[0.1em] Past Vote Outcomes"

// For Paper

estout RF_V1 TSLS_V1 RF_V2 TSLS_V2 ///
	using "$Results\\$program.tex", replace style(tex) type label	///
	stats(N r2_a F_fs, lab("Observations" "Adjusted $ R^2 $" "First-stage F-statistic (agglo cluster)") fmt(0 3 2)) ///
	cells(b(fmt(%9.3f)) se(star par fmt(%9.3f)))  ///
	collabels(none) ///
	mlabels(, span none prefix(\multicolumn{@span}{c}{) suffix(})) ///
	msign(--) starlevels($^c$ .1 $^b$ .05 $^a$ .01) ///
	keep(endog_mk instr lcrSR_F_N mean_votation) /// 
	order(endog_mk mean_votation lcrSR_F_N instr) /// 
	title(News and voting: Recentered instrument \citep{borusyak2020non}) ///	
	prehead("\begin{table}[!h]" ///
	"\begin{center}" ///
	"\begin{threeparttable}" ///
	"\begin{footnotesize}" ///
	"\caption{\small{@title}\label{$program}}" ///
	"\begin{tabular*}{\columnwidth}{@{\extracolsep{\stretch{1}}}l*{@M}{c}@{}}" ///
	"\hline" "\hline" ///	
	"\\" ///
	"Dependent Variable 		&\multicolumn{4}{c}{Minaret Ban approval (\%Yes)} 				\\" ///
	"							\cmidrule(lr){2-5}" ///
	"Randomizing				&\multicolumn{2}{c}{Location of crime} 					&\multicolumn{2}{c}{Date of crime} \\" ///
	"							&\multicolumn{2}{c}{(constant cases within period)} 	&\multicolumn{2}{c}{(constant cases within location)} \\" ///
	"							\cmidrule(lr){2-3} 				\cmidrule(lr){4-5}" ///
	"Specification				&\multicolumn{1}{c}{RF}			&\multicolumn{1}{c}{2SLS}		&\multicolumn{1}{c}{RF}		&\multicolumn{1}{c}{2SLS} \\" ///
	"							\cmidrule(lr){2-2}	\cmidrule(lr){3-3}	\cmidrule(lr){4-4}	\cmidrule(lr){5-5}	" ///
	"							&\multicolumn{1}{c}{(1)} 	&\multicolumn{1}{c}{(2)}  	&\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} \\") ///
	posthead("\hline" ///
	"\\") ///
	prefoot("\\" ///
	"\hline") ///
	postfoot("\hline" "\hline" ///
	"\end{tabular*}" /// 
	"\end{footnotesize}" ///
	"\begin{tablenotes}[normal,flushleft]" ///
	"\begin{scriptsize}" ///
	"\item \emph{Notes}:" /// 
	"The unit of observation is a municipality. " ///
	"Standard errors clustered at agglomeration level in parentheses. " ///
	"{$^c$} significant at 10\%; {$^b$} significant at 5\%; {$^a$} significant at 1\%. " ///
	"Columns (1) and (3) show the reduced-form estimates. Columns (2) and (4) present the 2SLS estimates. " /// 
	"Columns (1) and (2) randomize the crime location; Columns (3) and (4) the offence date. " ///
	"All regressions include the full vector of controls of Table \ref{Main_Table2}. " ///
	"" ///
	"\end{scriptsize}" ///
	"\end{tablenotes}" ///
	"\end{threeparttable}" ///
	"\end{center}" ///
	"\end{table}")

cap log close
